<script setup lang="ts">
import './mcp-style.scss'
import {inject, ref} from "vue";
import {Node} from "@antv/x6";
import {WebDiskDatabaseApi, WebDiskDatabaseVO} from "@/api/ai/webdiskdatabase";

const formData=reactive<any>({
  databaseId:undefined,
})
const database=ref<WebDiskDatabaseVO[]>()
const id=ref<string>()
const getNode=inject<()=>Node>('getNode')
const init=async ()=>{
  database.value=await WebDiskDatabaseApi.simpleList({})
}
onBeforeMount(()=>{
  if(getNode){
    const node=getNode()
    const d=node.getData()
    if (d){
      Object.assign(formData,d)
    }else {
      node.setData(formData)
    }
  }
})
onMounted(()=>{
  init()
})
if(getNode){
  const node=getNode()
  id.value=node.id
  node.setData(formData)
}
watch(formData,()=>{
  if(getNode){
    const node=getNode()
    node.setData(formData)
  }
},{deep:true,immediate:false})
</script>

<template>
  <div class="mcp-node">
    <div class="line5 mcp-title">
      <div class="flow-dot" magnet="true" :class="'flow-exec'" x-type="input-exec" :x-id="'input-exec_'+id"></div>
      <div>保存简历</div>
      <div class="flow-dot flow-right flow-exec" magnet="true" x-type="output-exec" :x-id="'output-exec_'+id"></div>
    </div>
    <div>
      <div class="line5">
        <div class="flow-dot flow-object" magnet="true" x-type="input-json" :x-id="'input-json_'+id"></div>
        <div class="">JSON实体</div>
      </div>
      <div class="line5">
        <div class="flow-dot flow-string" magnet="true" x-type="input-string" :x-id="'input-string_'+id"></div>
        <div>评语</div>
      </div>
      <div class="line5">
        <div class="flow-dot flow-number" magnet="true" x-type="input-int" :x-id="'input-int_'+id"></div>
        <div>评分</div>
      </div>
      <div style="color: #9f9f9f;font-size: 15px">元数据</div>
      <div class="line5">
        <div class="flow-dot flow-string" magnet="true" x-type="input-url" :x-id="'input-url_'+id"></div>
        <div>URL</div>
      </div>
    </div>
  </div>
</template>

<style scoped lang="scss">

</style>
